/*
 * FacadeSistema
 * 
 * This class implements IFacadeSistema
 * 
 * Author: Carmine Colicino, Luigi Di Martino
 * Version: 1.0
 * 
 * 2014 - Copyright by Team 6 - University of Salerno
*/

package it.unisa.udocs.facade;

import java.sql.SQLException;
import java.util.ArrayList;

import it.unisa.udocs.data.Account;
import it.unisa.udocs.data.AreaScientifica;
import it.unisa.udocs.data.Dipartimento;
import it.unisa.udocs.data.Evento;
import it.unisa.udocs.storage.DBSistema;

public class FacadeSistema implements IFacadeSistema{

	/**
	 * it's used to store a new Account in the system
	 * 
	 * @param account - The account 
	 * 
	 *  @return The Account'id  
	 * 
	 */
	public int creaAccount(Account account) {
		 return DBSistema.getInstance().creaAccount(account);
	}
	
	/**
	 * it's used to store a researcher in the system
	 * 
	 * @param account - The Researcher's account
	 * 
	 */
	public void creaRicercatore(Account account) {
		DBSistema.getInstance().creaRicercatore(account);
	}
	
	/**
	 *  it's used to store an University's Responsible 
	 * 
	 * @param account - The Responsible's account
	 * 
	 */
	public void creaResponsabileAteneo(Account account) {
		DBSistema.getInstance().creaResponsabileAteneo(account);
	}

	/**
	 * it's used to search  for an Account
	 * 
	 * @param campiCompilati -  An Array containing information about the Account what we are searching for
	 * 
	 *  @return A list of Account 
	 * 
	 */
	public ArrayList<Account> cercaAccount(ArrayList<String> campiCompilati) {
		return DBSistema.getInstance().cercaAccount(campiCompilati);
	}
	
	/**
	 * it's used to search for an Account specifying its ID 
	 * 
	 * @param id - The Account's ID 
	 * 
	 *  @return A list containing The account found 
	 * 
	 */
	public ArrayList<Account> getAccountById(int id) {
		return DBSistema.getInstance().getAccountById(id);
	}

	/**
	 * It's used to modify an Account
	 * 
	 * @param newAccount - The New Account
	 * 
	 */
	public void modificaAccount(Account newAccount) {
		DBSistema.getInstance().modificaAccount(newAccount);
	}

	/**
	 * It's used to remove an account from the storage 
	 * 
	 * @param account - The Account
	 * 
	 */
	public void eliminaAccount(Account account) {
		DBSistema.getInstance().eliminaAccount(account);
	}

	/**
	 * It's used to store a new Department in the system
	 * 
	 * @param dipartimento - The department 
	 * 
	 */
	public void creaDipartimento(Dipartimento dipartimento) {
		DBSistema.getInstance().creaDipartimento(dipartimento);
	}

	/**
	 * it's used to search for a Department
	 * 
	 * @param nome - The Department's name
	 * 
	 *  @return A list containing all Departments found 
	 * 
	 */
	public ArrayList<Dipartimento> cercaDipartimento(String nome) {
		return DBSistema.getInstance().cercaDipartimento(nome);
	}
	
	/**
	 * it's used to search for a specific Department specifying its ID 
	 * 
	 * @param id - The Department's id
	 * 
	 *  @return A list containing The Department found 
	 * 
	 */
	public ArrayList<Dipartimento> getDipartimentoById(int id) {
		return DBSistema.getInstance().getDipartimentoById(id);
	}

	/**
	 * it's used to modify a specific Department 
	 * 
	 * @param newDipartimento - The new Department
	 * 
	 */
	public void modificaDipartimento(Dipartimento newDipartimento) {
		DBSistema.getInstance().modificaDipartimento(newDipartimento);
	}

	/**
	 * It's used to remove from our storage a specific Department
	 * 
	 * @param dipartimento - The Department 
	 * 
	 */
	public void eliminaDipartimento(Dipartimento dipartimento) {
		DBSistema.getInstance().eliminaDipartimento(dipartimento);
	}

	/**
	 * This method is used to create a scientific area
	 * 
	 * @param area - The new Scientific area
	 * 
	 */
	public void creaAreaScientifica(AreaScientifica area) {
		DBSistema.getInstance().creaAreaScientifica(area);
	}

	/**
	 * It's used to search for a Scientific Area
	 * 
	 * @param nome - The Scientific Area's name
	 * @param codice - The Scientific Area's code
	 * 
	 *  @return A list with The Scientific Area found
	 * 
	 */
	public ArrayList<AreaScientifica> cercaAreaScientifica(
			String nome , String codice) {
		return DBSistema.getInstance().cercaAreaScientifica(nome, codice);
	}
	
	/**
	 * It's used to search for a Scientific Area specifying its ID 
	 * 
	 * @param id - The Scientific Area's Id 
	 * 
	 *  @return A list with The Scientific Area found
	 * 
	 */
	public ArrayList<AreaScientifica> getAreaScientificaById(int id) {
		return DBSistema.getInstance().getAreaScientificaById(id);
	}

	/**
	 * It's used to modify a Scientific Area
	 * 
	 * @param area - The new Scientific Area
	 * 
	 */
	public void modificaAreaScientifica(AreaScientifica area) {
		DBSistema.getInstance().modificaAreaScientifica(area);
	}

	/**
	 * It's used to delete a Scientific Area from the system
	 * 
	 * @param The Scientific Area to delete
	 * 
	 */
	public void eliminaAreaScientifica(AreaScientifica area) {
		DBSistema.getInstance().eliminaAreaScientifica(area);
	}

	/**
	 * It's used to store an Event in the System
	 * 
	 * @param evt - The Event
	 * 
	 */
	public void creaEvento(Evento evt) {
		DBSistema.getInstance().creaEvento(evt);
	}

	/**
	 * This method is used to search for an Event. 
	 * 
	 * @param nome - The Event's name
	 * @param bando - The Event's competition 
	 * 
	 *  @return The list of All Events found  
	 * 
	 */
	public ArrayList<Evento> cercaEvento(String nome, String bando) {
		return DBSistema.getInstance().cercaEvento(nome, bando);
	}
	
	/**
	 * This method search for an event specifying its  id
	 * 
	 * @param id - The Event's id 
	 * 
	 *  @return  The Event found  
	 * 
	 */
	public ArrayList<Evento> getEventoById(int id) {
		return DBSistema.getInstance().getEventoById(id);
	}

	/**
	 * It's used to modify an Event
	 * 
	 * @param evt - The Event to modify
	 * 
	 */
	public void modificaEvento(Evento evt) {
		DBSistema.getInstance().modificaEvento(evt);
	}

	/**
	 * it's used to remove an Event from the system 
	 * 
	 * @param evt - The Event to remove
	 * 
	 */
	public void eliminaEvento(Evento evt) {
		DBSistema.getInstance().eliminaEvento(evt);
	}
	
	/**
	 * It's used to search for all available Events 
	 * 
	 *  @return A list containing all available Events 
	 * 
	 */
	public ArrayList<Evento> getEventiDisponibili() {
		return DBSistema.getInstance().getEventiDisponibili();
	}

	/**
	 * It's used to search for all Departments 
	 * 
	 *  @return A list containing all departments 
	 * 
	 */
	public ArrayList<Dipartimento> getAllDipart() {
		try {
			return	DBSistema.getInstance().getAllDipart();
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
	}

	/**
	 *  It's used to search for all Scientific Areas
	 * 
	 *  @return A list containing all Scientific Areas 
	 * 
	 */
	public ArrayList<AreaScientifica> getAllAree(){
		try {
			return	DBSistema.getInstance().getAllAree();
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}

	}
	


}
